import java.util.Scanner;

public class Solution {
    static class ListNode{
        int val;
        ListNode next;

        public ListNode(){}

        public ListNode(int val) {
            this.val = val;
        }

        public ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }

    public int kthToLast(ListNode head, int k){
        ListNode fast = head;
        ListNode slow = head;
        int count = 0;
        while(count != k-1){
            fast = fast.next;
            if(fast == null){
                return -1;
            }
            count++;
        }
        while(fast.next != null){
            fast = fast.next;
            slow = slow.next;
        }
        return slow.val;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        ListNode node5 = new ListNode(5,null);
        ListNode node4 = new ListNode(4,node5);
        ListNode node3 = new ListNode(3,node4);
        ListNode node2 = new ListNode(2,node3);
        ListNode node1 = new ListNode(1,node2);

        int k = in.nextInt();

        Solution solution = new Solution();
        int result = solution.kthToLast(node1,k);
        System.out.println(result);
    }
}
